package com.wysql.thread.createthread3;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Demo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyCallable myCallable1 = new MyCallable();
        MyCallable myCallable2 = new MyCallable();

        //    Thread thread1 = new Thread(myCallable1);
        //可以获取线程执行完毕之后的结果.也可以作为参数传递给Thread对象
        FutureTask<String> futureTask = new FutureTask<>(myCallable1);
        Thread thread1 = new Thread(futureTask);
        thread1.start();
        String s = futureTask.get();
        System.err.println(s);
    }

}
